<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>AIfES 2: ailoss_crossentropy_default.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="AIfES_logo_small.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">AIfES 2
   &#160;<span id="projectnumber">2.0.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('ailoss__crossentropy__default_8h.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">ailoss_crossentropy_default.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Default implementation of the <a class="el" href="ailoss__crossentropy_8h.html">Cross-Entropy loss </a>.  
<a href="#details">More...</a></p>

<p><a href="ailoss__crossentropy__default_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:af023a0214bf4a9c22222ddcf8d42e5a8"><td class="memItemLeft" align="right" valign="top"><a id="af023a0214bf4a9c22222ddcf8d42e5a8"></a>
typedef struct <a class="el" href="structailoss__crossentropy.html">ailoss_crossentropy</a>&#160;</td><td class="memItemRight" valign="bottom"><b>ailoss_crossentropy_f32_t</b></td></tr>
<tr class="separator:af023a0214bf4a9c22222ddcf8d42e5a8"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:aa10b5c43deef1891d98cb8c45d57b3ee"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structailoss.html">ailoss_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ailoss__crossentropy__default_8h.html#aa10b5c43deef1891d98cb8c45d57b3ee">ailoss_crossentropy_f32_default</a> (<a class="el" href="structailoss__crossentropy.html">ailoss_crossentropy_f32_t</a> *loss, <a class="el" href="structailayer.html">ailayer_t</a> *input_layer)</td></tr>
<tr class="memdesc:aa10b5c43deef1891d98cb8c45d57b3ee"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes and connect a <a class="el" href="ailoss__crossentropy_8h.html">Cross-Entropy loss </a> with the <a class="el" href="aimath__f32_8h.html">F32 </a> default implementation using a mean reduction.  <a href="ailoss__crossentropy__default_8h.html#aa10b5c43deef1891d98cb8c45d57b3ee">More...</a><br /></td></tr>
<tr class="separator:aa10b5c43deef1891d98cb8c45d57b3ee"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a578c19c19b9d4e699582501124bfb67b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structailoss.html">ailoss_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ailoss__crossentropy__default_8h.html#a578c19c19b9d4e699582501124bfb67b">ailoss_crossentropy_sum_f32_default</a> (<a class="el" href="structailoss__crossentropy.html">ailoss_crossentropy_f32_t</a> *loss, <a class="el" href="structailayer.html">ailayer_t</a> *input_layer)</td></tr>
<tr class="memdesc:a578c19c19b9d4e699582501124bfb67b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes and connect a <a class="el" href="ailoss__crossentropy_8h.html">Cross-Entropy loss </a> with the <a class="el" href="aimath__f32_8h.html">F32 </a> default implementation using a sum reduction.  <a href="ailoss__crossentropy__default_8h.html#a578c19c19b9d4e699582501124bfb67b">More...</a><br /></td></tr>
<tr class="separator:a578c19c19b9d4e699582501124bfb67b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9c50fc1211ca8126adec060e7db1bbc6"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structailoss.html">ailoss_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ailoss__crossentropy__default_8h.html#a9c50fc1211ca8126adec060e7db1bbc6">ailoss_crossentropy_mean_f32_default</a> (<a class="el" href="structailoss__crossentropy.html">ailoss_crossentropy_f32_t</a> *loss, <a class="el" href="structailayer.html">ailayer_t</a> *input_layer)</td></tr>
<tr class="memdesc:a9c50fc1211ca8126adec060e7db1bbc6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes and connect a <a class="el" href="ailoss__crossentropy_8h.html">Cross-Entropy loss </a> with the <a class="el" href="aimath__f32_8h.html">F32 </a> default implementation using a mean reduction.  <a href="ailoss__crossentropy__default_8h.html#a9c50fc1211ca8126adec060e7db1bbc6">More...</a><br /></td></tr>
<tr class="separator:a9c50fc1211ca8126adec060e7db1bbc6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a01f977cc97f44940f402462686e13de3"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structailoss.html">ailoss_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ailoss__crossentropy__default_8h.html#a01f977cc97f44940f402462686e13de3">ailoss_crossentropy_sparse8_f32_default</a> (<a class="el" href="structailoss__crossentropy.html">ailoss_crossentropy_f32_t</a> *loss, <a class="el" href="structailayer.html">ailayer_t</a> *input_layer)</td></tr>
<tr class="memdesc:a01f977cc97f44940f402462686e13de3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes and connect a <a class="el" href="ailoss__crossentropy_8h.html">Cross-Entropy loss </a> with the <a class="el" href="aimath__f32_8h.html">F32 </a> default implementation for sparse labels using a mean reduction.  <a href="ailoss__crossentropy__default_8h.html#a01f977cc97f44940f402462686e13de3">More...</a><br /></td></tr>
<tr class="separator:a01f977cc97f44940f402462686e13de3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6d07fc7fe0472790176e0d62261e1acf"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structailoss.html">ailoss_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ailoss__crossentropy__default_8h.html#a6d07fc7fe0472790176e0d62261e1acf">ailoss_crossentropy_sum_sparse8_f32_default</a> (<a class="el" href="structailoss__crossentropy.html">ailoss_crossentropy_f32_t</a> *loss, <a class="el" href="structailayer.html">ailayer_t</a> *input_layer)</td></tr>
<tr class="memdesc:a6d07fc7fe0472790176e0d62261e1acf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes and connect a <a class="el" href="ailoss__crossentropy_8h.html">Cross-Entropy loss </a> with the <a class="el" href="aimath__f32_8h.html">F32 </a> default implementation for sparse labels using a sum reduction.  <a href="ailoss__crossentropy__default_8h.html#a6d07fc7fe0472790176e0d62261e1acf">More...</a><br /></td></tr>
<tr class="separator:a6d07fc7fe0472790176e0d62261e1acf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a921b0cf86d01c60c06ea70dfceafee9c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structailoss.html">ailoss_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ailoss__crossentropy__default_8h.html#a921b0cf86d01c60c06ea70dfceafee9c">ailoss_crossentropy_mean_sparse8_f32_default</a> (<a class="el" href="structailoss__crossentropy.html">ailoss_crossentropy_f32_t</a> *loss, <a class="el" href="structailayer.html">ailayer_t</a> *input_layer)</td></tr>
<tr class="memdesc:a921b0cf86d01c60c06ea70dfceafee9c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes and connect a <a class="el" href="ailoss__crossentropy_8h.html">Cross-Entropy loss </a> with the <a class="el" href="aimath__f32_8h.html">F32 </a> default implementation for sparse labels using a mean reduction.  <a href="ailoss__crossentropy__default_8h.html#a921b0cf86d01c60c06ea70dfceafee9c">More...</a><br /></td></tr>
<tr class="separator:a921b0cf86d01c60c06ea70dfceafee9c"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Default implementation of the <a class="el" href="ailoss__crossentropy_8h.html">Cross-Entropy loss </a>. </p>
<dl class="section version"><dt>Version</dt><dd>2.2.0 </dd></dl>
<dl class="section copyright"><dt>Copyright</dt><dd>Copyright (C) 2020-2023 Fraunhofer Institute for Microelectronic Circuits and Systems. All rights reserved.<br  />
<br  />
 AIfES is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.<br  />
<br  />
 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.<br  />
<br  />
 You should have received a copy of the GNU Affero General Public License along with this program. If not, see <a href="https://www.gnu.org/licenses/">https://www.gnu.org/licenses/</a>.</dd></dl>
<p>Hardware independent implementations of the Cross-Entropy loss in <a class="el" href="aimath__f32_8h.html">F32 </a> data-type. For more information about the Cross-Entropy loss refer to <a class="el" href="ailoss__mse_8h.html" title="Base loss  implementation of the Mean Squared Error (MSE) loss.">ailoss_mse.h</a>. </p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="aa10b5c43deef1891d98cb8c45d57b3ee"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa10b5c43deef1891d98cb8c45d57b3ee">&#9670;&nbsp;</a></span>ailoss_crossentropy_f32_default()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structailoss.html">ailoss_t</a>* ailoss_crossentropy_f32_default </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structailoss__crossentropy.html">ailoss_crossentropy_f32_t</a> *&#160;</td>
          <td class="paramname"><em>loss</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structailayer.html">ailayer_t</a> *&#160;</td>
          <td class="paramname"><em>input_layer</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initializes and connect a <a class="el" href="ailoss__crossentropy_8h.html">Cross-Entropy loss </a> with the <a class="el" href="aimath__f32_8h.html">F32 </a> default implementation using a mean reduction. </p>
<p>The labels must me either binary (when the output layer is a Sigmoid layer), for example </p><p class="formulaDsp">
\[ \left( \begin{array}{ccc} 1 &amp; 0 &amp; 0 &amp; 1 \\ 1 &amp; 1 &amp; 1 &amp; 0 \\ 0 &amp; 0 &amp; 1 &amp; 0 \end{array}\right) \]
</p>
<p>or row wise one-hot encoded (when the output layer is a Softmax layer), for example </p><p class="formulaDsp">
\[ \left( \begin{array}{ccc} 0 &amp; 0 &amp; 0 &amp; 1 \\ 1 &amp; 0 &amp; 0 &amp; 0 \\ 0 &amp; 0 &amp; 1 &amp; 0 \end{array}\right) \]
</p>
<p>If you want to provide labels as integers, please use <a class="el" href="ailoss__crossentropy__default_8h.html#a01f977cc97f44940f402462686e13de3" title="Initializes and connect a Cross-Entropy loss  with the F32  default implementation for sparse labels ...">ailoss_crossentropy_sparse8_f32_default()</a> loss.</p>
<p><b>Example:</b> Create the loss structure:<br  />
</p><div class="fragment"><div class="line"><a class="code" href="structailoss__crossentropy.html">ailoss_crossentropy_f32_t</a> crossentropy_loss;</div>
<div class="ttc" id="astructailoss__crossentropy_html"><div class="ttname"><a href="structailoss__crossentropy.html">ailoss_crossentropy</a></div><div class="ttdoc">General Cross-Entropy loss  struct.</div><div class="ttdef"><b>Definition:</b> ailoss_crossentropy.h:62</div></div>
</div><!-- fragment --><p><b>Example:</b> Initialize and connect the loss to the layer structure:<br  />
</p><div class="fragment"><div class="line"><a class="code" href="structaimodel.html">aimodel_t</a> model;</div>
<div class="line">...</div>
<div class="line">model.<a class="code" href="structaimodel.html#a7c7ad89e7d15631b3f5893b8f19030ef">output_layer</a> = <a class="code" href="ailayer__sigmoid__default_8h.html#a1ec45b121e81b85e2109f0072d46f602">ailayer_sigmoid_f32_default</a>(&amp;sigmoid_layer, x);</div>
<div class="line"> </div>
<div class="line">model.<a class="code" href="structaimodel.html#ad08c61cef46d4042c62d8cdeba81986f">loss</a> = <a class="code" href="ailoss__crossentropy__default_8h.html#aa10b5c43deef1891d98cb8c45d57b3ee">ailoss_crossentropy_f32_default</a>(&amp;crossentropy_loss, model.<a class="code" href="structaimodel.html#a7c7ad89e7d15631b3f5893b8f19030ef">output_layer</a>);</div>
<div class="ttc" id="aailayer__sigmoid__default_8h_html_a1ec45b121e81b85e2109f0072d46f602"><div class="ttname"><a href="ailayer__sigmoid__default_8h.html#a1ec45b121e81b85e2109f0072d46f602">ailayer_sigmoid_f32_default</a></div><div class="ttdeci">ailayer_t * ailayer_sigmoid_f32_default(ailayer_sigmoid_f32_t *layer, ailayer_t *input_layer)</div><div class="ttdoc">Initializes and connect a Sigmoid layer  with the F32  default implementation.</div></div>
<div class="ttc" id="aailoss__crossentropy__default_8h_html_aa10b5c43deef1891d98cb8c45d57b3ee"><div class="ttname"><a href="ailoss__crossentropy__default_8h.html#aa10b5c43deef1891d98cb8c45d57b3ee">ailoss_crossentropy_f32_default</a></div><div class="ttdeci">ailoss_t * ailoss_crossentropy_f32_default(ailoss_crossentropy_f32_t *loss, ailayer_t *input_layer)</div><div class="ttdoc">Initializes and connect a Cross-Entropy loss  with the F32  default implementation using a mean reduc...</div></div>
<div class="ttc" id="astructaimodel_html"><div class="ttname"><a href="structaimodel.html">aimodel</a></div><div class="ttdoc">AIfES artificial neural network model.</div><div class="ttdef"><b>Definition:</b> aifes_core.h:181</div></div>
<div class="ttc" id="astructaimodel_html_a7c7ad89e7d15631b3f5893b8f19030ef"><div class="ttname"><a href="structaimodel.html#a7c7ad89e7d15631b3f5893b8f19030ef">aimodel::output_layer</a></div><div class="ttdeci">ailayer_t * output_layer</div><div class="ttdoc">Output layer of the model.</div><div class="ttdef"><b>Definition:</b> aifes_core.h:183</div></div>
<div class="ttc" id="astructaimodel_html_ad08c61cef46d4042c62d8cdeba81986f"><div class="ttname"><a href="structaimodel.html#ad08c61cef46d4042c62d8cdeba81986f">aimodel::loss</a></div><div class="ttdeci">ailoss_t * loss</div><div class="ttdoc">The loss or cost function of the model (only for training).</div><div class="ttdef"><b>Definition:</b> aifes_core.h:188</div></div>
</div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">*loss</td><td>The loss structure to initialize. </td></tr>
    <tr><td class="paramname">*input_layer</td><td>The output layer of the model (<b>Must be either a Sigmoid or a Softmax layer!</b>). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The (successfully) initialized loss structure. </dd></dl>

</div>
</div>
<a id="a9c50fc1211ca8126adec060e7db1bbc6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9c50fc1211ca8126adec060e7db1bbc6">&#9670;&nbsp;</a></span>ailoss_crossentropy_mean_f32_default()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structailoss.html">ailoss_t</a>* ailoss_crossentropy_mean_f32_default </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structailoss__crossentropy.html">ailoss_crossentropy_f32_t</a> *&#160;</td>
          <td class="paramname"><em>loss</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structailayer.html">ailayer_t</a> *&#160;</td>
          <td class="paramname"><em>input_layer</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initializes and connect a <a class="el" href="ailoss__crossentropy_8h.html">Cross-Entropy loss </a> with the <a class="el" href="aimath__f32_8h.html">F32 </a> default implementation using a mean reduction. </p>
<p>The labels must me either binary (when the output layer is a Sigmoid layer), for example </p><p class="formulaDsp">
\[ \left( \begin{array}{ccc} 1 &amp; 0 &amp; 0 &amp; 1 \\ 1 &amp; 1 &amp; 1 &amp; 0 \\ 0 &amp; 0 &amp; 1 &amp; 0 \end{array}\right) \]
</p>
<p>or row wise one-hot encoded (when the output layer is a Softmax layer), for example </p><p class="formulaDsp">
\[ \left( \begin{array}{ccc} 0 &amp; 0 &amp; 0 &amp; 1 \\ 1 &amp; 0 &amp; 0 &amp; 0 \\ 0 &amp; 0 &amp; 1 &amp; 0 \end{array}\right) \]
</p>
<p>If you want to provide labels as integers, please use <a class="el" href="ailoss__crossentropy__default_8h.html#a01f977cc97f44940f402462686e13de3" title="Initializes and connect a Cross-Entropy loss  with the F32  default implementation for sparse labels ...">ailoss_crossentropy_sparse8_f32_default()</a> loss.</p>
<p><b>Example:</b> Create the loss structure:<br  />
</p><div class="fragment"><div class="line"><a class="code" href="structailoss__crossentropy.html">ailoss_crossentropy_f32_t</a> crossentropy_loss;</div>
</div><!-- fragment --><p><b>Example:</b> Initialize and connect the loss to the layer structure:<br  />
</p><div class="fragment"><div class="line"><a class="code" href="structaimodel.html">aimodel_t</a> model;</div>
<div class="line">...</div>
<div class="line">model.<a class="code" href="structaimodel.html#a7c7ad89e7d15631b3f5893b8f19030ef">output_layer</a> = <a class="code" href="ailayer__sigmoid__default_8h.html#a1ec45b121e81b85e2109f0072d46f602">ailayer_sigmoid_f32_default</a>(&amp;sigmoid_layer, x);</div>
<div class="line"> </div>
<div class="line">model.<a class="code" href="structaimodel.html#ad08c61cef46d4042c62d8cdeba81986f">loss</a> = <a class="code" href="ailoss__crossentropy__default_8h.html#aa10b5c43deef1891d98cb8c45d57b3ee">ailoss_crossentropy_f32_default</a>(&amp;crossentropy_loss, model.<a class="code" href="structaimodel.html#a7c7ad89e7d15631b3f5893b8f19030ef">output_layer</a>);</div>
</div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">*loss</td><td>The loss structure to initialize. </td></tr>
    <tr><td class="paramname">*input_layer</td><td>The output layer of the model (<b>Must be either a Sigmoid or a Softmax layer!</b>). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The (successfully) initialized loss structure. </dd></dl>

</div>
</div>
<a id="a921b0cf86d01c60c06ea70dfceafee9c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a921b0cf86d01c60c06ea70dfceafee9c">&#9670;&nbsp;</a></span>ailoss_crossentropy_mean_sparse8_f32_default()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structailoss.html">ailoss_t</a>* ailoss_crossentropy_mean_sparse8_f32_default </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structailoss__crossentropy.html">ailoss_crossentropy_f32_t</a> *&#160;</td>
          <td class="paramname"><em>loss</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structailayer.html">ailayer_t</a> *&#160;</td>
          <td class="paramname"><em>input_layer</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initializes and connect a <a class="el" href="ailoss__crossentropy_8h.html">Cross-Entropy loss </a> with the <a class="el" href="aimath__f32_8h.html">F32 </a> default implementation for sparse labels using a mean reduction. </p>
<p>This loss is meant for single label classification purposes. It expects the target data / labels to be an 8-bit integer tensor (<a class="el" href="aimath__u8_8h.html">U8 </a>) with the true-class index.</p>
<p>For example the matrix </p><p class="formulaDsp">
\[ \left( \begin{array}{ccc} 0 &amp; 0 &amp; 0 &amp; 1 \\ 1 &amp; 0 &amp; 0 &amp; 0 \\ 0 &amp; 0 &amp; 1 &amp; 0 \end{array}\right) \]
</p>
<p> in sparse representation is </p><p class="formulaDsp">
\[ \left( \begin{array}{ccc} 3 \\ 0 \\ 2 \end{array}\right) \]
</p>
<p> and can be created with </p><div class="fragment"><div class="line">uint16_t t_shape[2] = {3, 1};</div>
<div class="line">uint8_t t_data[2*1] = {3,</div>
<div class="line">                       0,</div>
<div class="line">                       2};</div>
<div class="line"><a class="code" href="structaitensor.html">aitensor_t</a> t = AITENSOR_2D_U8(t_shape, t_data);</div>
<div class="ttc" id="astructaitensor_html"><div class="ttname"><a href="structaitensor.html">aitensor</a></div><div class="ttdoc">A tensor in AIfES.</div><div class="ttdef"><b>Definition:</b> aifes_math.h:89</div></div>
</div><!-- fragment --><p>Example: Create the loss structure:<br  />
</p><div class="fragment"><div class="line"><a class="code" href="structailoss__crossentropy.html">ailoss_crossentropy_f32_t</a> crossentropy_loss;</div>
</div><!-- fragment --><p>Example: Initialize and connect the loss to the layer structure:<br  />
</p><div class="fragment"><div class="line"><a class="code" href="structaimodel.html">aimodel_t</a> model;</div>
<div class="line">...</div>
<div class="line">model.<a class="code" href="structaimodel.html#a7c7ad89e7d15631b3f5893b8f19030ef">output_layer</a> = <a class="code" href="ailayer__softmax__default_8h.html#a3a89bb8691ee208550e0b267355679ea">ailayer_softmax_f32_default</a>(&amp;softmax_layer, x);</div>
<div class="line"> </div>
<div class="line">model.<a class="code" href="structaimodel.html#ad08c61cef46d4042c62d8cdeba81986f">loss</a> = <a class="code" href="ailoss__crossentropy__default_8h.html#a01f977cc97f44940f402462686e13de3">ailoss_crossentropy_sparse8_f32_default</a>(&amp;crossentropy_loss, model.<a class="code" href="structaimodel.html#a7c7ad89e7d15631b3f5893b8f19030ef">output_layer</a>);</div>
<div class="ttc" id="aailayer__softmax__default_8h_html_a3a89bb8691ee208550e0b267355679ea"><div class="ttname"><a href="ailayer__softmax__default_8h.html#a3a89bb8691ee208550e0b267355679ea">ailayer_softmax_f32_default</a></div><div class="ttdeci">ailayer_t * ailayer_softmax_f32_default(ailayer_softmax_f32_t *layer, ailayer_t *input_layer)</div><div class="ttdoc">Initializes and connect an Softmax layer  with the F32  default implementation.</div></div>
<div class="ttc" id="aailoss__crossentropy__default_8h_html_a01f977cc97f44940f402462686e13de3"><div class="ttname"><a href="ailoss__crossentropy__default_8h.html#a01f977cc97f44940f402462686e13de3">ailoss_crossentropy_sparse8_f32_default</a></div><div class="ttdeci">ailoss_t * ailoss_crossentropy_sparse8_f32_default(ailoss_crossentropy_f32_t *loss, ailayer_t *input_layer)</div><div class="ttdoc">Initializes and connect a Cross-Entropy loss  with the F32  default implementation for sparse labels ...</div></div>
</div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">*loss</td><td>The loss structure to initialize. </td></tr>
    <tr><td class="paramname">*input_layer</td><td>The output layer of the model (<b>Must be a Softmax layer!</b>). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The (successfully) initialized loss structure. </dd></dl>

</div>
</div>
<a id="a01f977cc97f44940f402462686e13de3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a01f977cc97f44940f402462686e13de3">&#9670;&nbsp;</a></span>ailoss_crossentropy_sparse8_f32_default()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structailoss.html">ailoss_t</a>* ailoss_crossentropy_sparse8_f32_default </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structailoss__crossentropy.html">ailoss_crossentropy_f32_t</a> *&#160;</td>
          <td class="paramname"><em>loss</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structailayer.html">ailayer_t</a> *&#160;</td>
          <td class="paramname"><em>input_layer</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initializes and connect a <a class="el" href="ailoss__crossentropy_8h.html">Cross-Entropy loss </a> with the <a class="el" href="aimath__f32_8h.html">F32 </a> default implementation for sparse labels using a mean reduction. </p>
<p>This loss is meant for single label classification purposes. It expects the target data / labels to be an 8-bit integer tensor (<a class="el" href="aimath__u8_8h.html">U8 </a>) with the true-class index.</p>
<p>For example the matrix </p><p class="formulaDsp">
\[ \left( \begin{array}{ccc} 0 &amp; 0 &amp; 0 &amp; 1 \\ 1 &amp; 0 &amp; 0 &amp; 0 \\ 0 &amp; 0 &amp; 1 &amp; 0 \end{array}\right) \]
</p>
<p> in sparse representation is </p><p class="formulaDsp">
\[ \left( \begin{array}{ccc} 3 \\ 0 \\ 2 \end{array}\right) \]
</p>
<p> and can be created with </p><div class="fragment"><div class="line">uint16_t t_shape[2] = {3, 1};</div>
<div class="line">uint8_t t_data[2*1] = {3,</div>
<div class="line">                       0,</div>
<div class="line">                       2};</div>
<div class="line"><a class="code" href="structaitensor.html">aitensor_t</a> t = AITENSOR_2D_U8(t_shape, t_data);</div>
</div><!-- fragment --><p>Example: Create the loss structure:<br  />
</p><div class="fragment"><div class="line"><a class="code" href="structailoss__crossentropy.html">ailoss_crossentropy_f32_t</a> crossentropy_loss;</div>
</div><!-- fragment --><p>Example: Initialize and connect the loss to the layer structure:<br  />
</p><div class="fragment"><div class="line"><a class="code" href="structaimodel.html">aimodel_t</a> model;</div>
<div class="line">...</div>
<div class="line">model.<a class="code" href="structaimodel.html#a7c7ad89e7d15631b3f5893b8f19030ef">output_layer</a> = <a class="code" href="ailayer__softmax__default_8h.html#a3a89bb8691ee208550e0b267355679ea">ailayer_softmax_f32_default</a>(&amp;softmax_layer, x);</div>
<div class="line"> </div>
<div class="line">model.<a class="code" href="structaimodel.html#ad08c61cef46d4042c62d8cdeba81986f">loss</a> = <a class="code" href="ailoss__crossentropy__default_8h.html#a01f977cc97f44940f402462686e13de3">ailoss_crossentropy_sparse8_f32_default</a>(&amp;crossentropy_loss, model.<a class="code" href="structaimodel.html#a7c7ad89e7d15631b3f5893b8f19030ef">output_layer</a>);</div>
</div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">*loss</td><td>The loss structure to initialize. </td></tr>
    <tr><td class="paramname">*input_layer</td><td>The output layer of the model (<b>Must be a Softmax layer!</b>). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The (successfully) initialized loss structure. </dd></dl>

</div>
</div>
<a id="a578c19c19b9d4e699582501124bfb67b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a578c19c19b9d4e699582501124bfb67b">&#9670;&nbsp;</a></span>ailoss_crossentropy_sum_f32_default()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structailoss.html">ailoss_t</a>* ailoss_crossentropy_sum_f32_default </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structailoss__crossentropy.html">ailoss_crossentropy_f32_t</a> *&#160;</td>
          <td class="paramname"><em>loss</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structailayer.html">ailayer_t</a> *&#160;</td>
          <td class="paramname"><em>input_layer</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initializes and connect a <a class="el" href="ailoss__crossentropy_8h.html">Cross-Entropy loss </a> with the <a class="el" href="aimath__f32_8h.html">F32 </a> default implementation using a sum reduction. </p>
<p>The labels must me either binary (when the output layer is a Sigmoid layer), for example </p><p class="formulaDsp">
\[ \left( \begin{array}{ccc} 1 &amp; 0 &amp; 0 &amp; 1 \\ 1 &amp; 1 &amp; 1 &amp; 0 \\ 0 &amp; 0 &amp; 1 &amp; 0 \end{array}\right) \]
</p>
<p>or row wise one-hot encoded (when the output layer is a Softmax layer), for example </p><p class="formulaDsp">
\[ \left( \begin{array}{ccc} 0 &amp; 0 &amp; 0 &amp; 1 \\ 1 &amp; 0 &amp; 0 &amp; 0 \\ 0 &amp; 0 &amp; 1 &amp; 0 \end{array}\right) \]
</p>
<p>If you want to provide labels as integers, please use <a class="el" href="ailoss__crossentropy__default_8h.html#a01f977cc97f44940f402462686e13de3" title="Initializes and connect a Cross-Entropy loss  with the F32  default implementation for sparse labels ...">ailoss_crossentropy_sparse8_f32_default()</a> loss.</p>
<p><b>Example:</b> Create the loss structure:<br  />
</p><div class="fragment"><div class="line"><a class="code" href="structailoss__crossentropy.html">ailoss_crossentropy_f32_t</a> crossentropy_loss;</div>
</div><!-- fragment --><p><b>Example:</b> Initialize and connect the loss to the layer structure:<br  />
</p><div class="fragment"><div class="line"><a class="code" href="structaimodel.html">aimodel_t</a> model;</div>
<div class="line">...</div>
<div class="line">model.<a class="code" href="structaimodel.html#a7c7ad89e7d15631b3f5893b8f19030ef">output_layer</a> = <a class="code" href="ailayer__sigmoid__default_8h.html#a1ec45b121e81b85e2109f0072d46f602">ailayer_sigmoid_f32_default</a>(&amp;sigmoid_layer, x);</div>
<div class="line"> </div>
<div class="line">model.<a class="code" href="structaimodel.html#ad08c61cef46d4042c62d8cdeba81986f">loss</a> = <a class="code" href="ailoss__crossentropy__default_8h.html#aa10b5c43deef1891d98cb8c45d57b3ee">ailoss_crossentropy_f32_default</a>(&amp;crossentropy_loss, model.<a class="code" href="structaimodel.html#a7c7ad89e7d15631b3f5893b8f19030ef">output_layer</a>);</div>
</div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">*loss</td><td>The loss structure to initialize. </td></tr>
    <tr><td class="paramname">*input_layer</td><td>The output layer of the model (<b>Must be either a Sigmoid or a Softmax layer!</b>). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The (successfully) initialized loss structure. </dd></dl>

</div>
</div>
<a id="a6d07fc7fe0472790176e0d62261e1acf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6d07fc7fe0472790176e0d62261e1acf">&#9670;&nbsp;</a></span>ailoss_crossentropy_sum_sparse8_f32_default()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structailoss.html">ailoss_t</a>* ailoss_crossentropy_sum_sparse8_f32_default </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structailoss__crossentropy.html">ailoss_crossentropy_f32_t</a> *&#160;</td>
          <td class="paramname"><em>loss</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structailayer.html">ailayer_t</a> *&#160;</td>
          <td class="paramname"><em>input_layer</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initializes and connect a <a class="el" href="ailoss__crossentropy_8h.html">Cross-Entropy loss </a> with the <a class="el" href="aimath__f32_8h.html">F32 </a> default implementation for sparse labels using a sum reduction. </p>
<p>This loss is meant for single label classification purposes. It expects the target data / labels to be an 8-bit integer tensor (<a class="el" href="aimath__u8_8h.html">U8 </a>) with the true-class index.</p>
<p>For example the matrix </p><p class="formulaDsp">
\[ \left( \begin{array}{ccc} 0 &amp; 0 &amp; 0 &amp; 1 \\ 1 &amp; 0 &amp; 0 &amp; 0 \\ 0 &amp; 0 &amp; 1 &amp; 0 \end{array}\right) \]
</p>
<p> in sparse representation is </p><p class="formulaDsp">
\[ \left( \begin{array}{ccc} 3 \\ 0 \\ 2 \end{array}\right) \]
</p>
<p> and can be created with </p><div class="fragment"><div class="line">uint16_t t_shape[2] = {3, 1};</div>
<div class="line">uint8_t t_data[2*1] = {3,</div>
<div class="line">                       0,</div>
<div class="line">                       2};</div>
<div class="line"><a class="code" href="structaitensor.html">aitensor_t</a> t = AITENSOR_2D_U8(t_shape, t_data);</div>
</div><!-- fragment --><p>Example: Create the loss structure:<br  />
</p><div class="fragment"><div class="line"><a class="code" href="structailoss__crossentropy.html">ailoss_crossentropy_f32_t</a> crossentropy_loss;</div>
</div><!-- fragment --><p>Example: Initialize and connect the loss to the layer structure:<br  />
</p><div class="fragment"><div class="line"><a class="code" href="structaimodel.html">aimodel_t</a> model;</div>
<div class="line">...</div>
<div class="line">model.<a class="code" href="structaimodel.html#a7c7ad89e7d15631b3f5893b8f19030ef">output_layer</a> = <a class="code" href="ailayer__softmax__default_8h.html#a3a89bb8691ee208550e0b267355679ea">ailayer_softmax_f32_default</a>(&amp;softmax_layer, x);</div>
<div class="line"> </div>
<div class="line">model.<a class="code" href="structaimodel.html#ad08c61cef46d4042c62d8cdeba81986f">loss</a> = <a class="code" href="ailoss__crossentropy__default_8h.html#a01f977cc97f44940f402462686e13de3">ailoss_crossentropy_sparse8_f32_default</a>(&amp;crossentropy_loss, model.<a class="code" href="structaimodel.html#a7c7ad89e7d15631b3f5893b8f19030ef">output_layer</a>);</div>
</div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">*loss</td><td>The loss structure to initialize. </td></tr>
    <tr><td class="paramname">*input_layer</td><td>The output layer of the model (<b>Must be a Softmax layer!</b>). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The (successfully) initialized loss structure. </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_1e5d3661ed79af157d57e64a38265d09.html">basic</a></li><li class="navelem"><a class="el" href="dir_6f3c54947e40ccd50db54894d07fbfc0.html">default</a></li><li class="navelem"><a class="el" href="dir_b5fd7924637b67fdb5220334f57dc3ab.html">ailoss</a></li><li class="navelem"><a class="el" href="ailoss__crossentropy__default_8h.html">ailoss_crossentropy_default.h</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
